"""This module is a wrapper for database requests"""

from pypalo.basic import response, url, default, arguments

request_group="database"

def cubes(database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/cubes[?PARAMETER1=value[&...]].
	
	Parameters: 
		database [identifier] <Identifier of the database>
		show_normal [identifier] <Show cubes of type normal (0=do not show normal cubes, 1=show (default))>
		show_system [identifier] <Show cubes of type system (0=do not show system cubes (default), 1=show)>
		show_attribute [identifier] <Show cubes of type attribute (0=do not show attribute cubes (default), 1=show)>
		show_info [identifier] <Show cubes of type user info (0=do not show user info cubes (default), 1=show)>
		show_gputype [identifier] <Show cubes of type gpu type (0=do not show gpu type cubes, 1=show (default))>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
			
	Result:
		0 cube [identifier] <Identifier of the cube>
		1 name_cube [string] <Name of the cube>
		2 number_dimensions [integer] <Number of dimensions>
		3 dimensions [integer] <Comma separate list of dimension identifiers>
		4 number_cells [integer] <Total number of cells>
		5 number_filled_cells [integer] <Number of filled numeric base cells plus number of filled string cells>
		6 status [integer] <Status of cube (0=unloaded, 1=loaded and 2=changed)>
		7 type [integer] <Type of cube (0=normal, 1=system, 2=attribute, 3=user info, 4=gpu type)>
		8 cube_token [integer] <The cube token of the cube>

	More info at http://host:port/api/database/cubes
	'''
	#beginning of function suite
	request_name="cubes"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def create(new_name, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/create[?PARAMETER1=value[&...]].
	
	Parameters: 
		new_name [string] <Name of the new database>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
		type [identifier] <Type of the database (0=normal (default), 3=user info)>
		
	Result:
		0 database [identifier] <Identifier of the database>
		1 name_database [string] <Name of the database>
		2 number_dimensions [integer] <Number of dimensions in the database>
		3 number_cubes [integer] <Number of cubes in the database>
		4 status [integer] <Status of database (0=unloaded, 1=loaded and 2=changed)>
		5 type [integer] <Type of database (0=normal, 1=system, 3=user info)>

	More info at http://host:port/api/database/create
	'''
	#beginning of function suite
	request_name="create"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def destroy(database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/destroy[?PARAMETER1=value[&...]].
	
	Parameters: 
		database [identifier] <Identifier of the database>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
	
	More info at http://host:port/api/database/destroy
	'''
	#beginning of function suite
	request_name="destroy"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def dimensions(database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/dimensions[?PARAMETER1=value[&...]].
	
	Parameters: 
		database [identifier] <Identifier of the database>
		show_normal [identifier] <Show dimensions of type normal (0=do not show normal dimensions, 1=show (default))>
		show_system [identifier] <Show dimensions of type system (0=do not show system dimensions (default), 1=show)>
		show_attribute [identifier] <Show dimensions of type attribute (0=do not show attribute dimensions (default), 1=show)>
		show_info [identifier] <Show dimensions of type user info (0=do not show user info dimensions (default), 1=show)>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
		
	Result:
		0 dimension [identifier] <Identifier of the dimension>
		1 name_dimension [string] <Name of the dimension>
		2 number_elements [integer] <Number of elements>
		3 maximum_level [integer] <Maximum level of the dimension>
		4 maximum_indent [integer] <Maximum indent of the dimension>
		5 maximum_depth [integer] <Maximum depth of the dimension>
		6 type [integer] <Type of dimension (0=normal, 1=system, 2=attribute, 3=user info)>
		7 attributes_dimension [identifier] <Identifier of the attributes dimension of a normal dimension or the identifier of the normal dimension associated to a attributes dimension.>
		8 attributes_cube [identifier] <Identifier of the attributes cube. (only for normal dimensions)>
		9 rights_cube [identifier] <Identifier of the rights cube. (only for normal dimensions)>
		10 dimension_token [integer] <The dimension token of the dimension>

	More info at http://host:port/api/database/dimensions
	'''
	#beginning of function suite
	request_name="dimensions"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def info(database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/info[?PARAMETER1=value[&...]].
	
	Parameters: 
		database [identifier] <Identifier of the database>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 database [identifier] <Identifier of the database>
		1 name_database [string] <Name of the database>
		2 number_dimensions [integer] <Number of dimensions in the database>
		3 number_cubes [integer] <Number of cubes in the database>
		4 status [integer] <Status of database (0=unloaded, 1=loaded and 2=changed)>
		5 type [integer] <Type of database (0=normal, 1=system, 3=user info)>
		6 database_token [integer] <The database token of the database>
	
	More info at http://host:port/api/database/info
	'''
	#beginning of function suite
	request_name="info"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def load(database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/load[?PARAMETER1=value[&...]].
	
	Parameters: 
		database [identifier] <Identifier of the database>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
	
	More info at http://host:port/api/database/load
	'''
	#beginning of function suite
	request_name="load"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def rename(new_name, database, sid, host=default["host"], port=default["port"], **keywords):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/rename[?PARAMETER1=value[&...]].
	
	Parameters: 
		new_name [string] <Name of the new database>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
		type [identifier] <Type of the database (0=normal (default), 3=user info)>
	
	Result:
		0 database [identifier] <Identifier of the database>
		1 name_database [string] <Name of the database>
		2 number_dimensions [integer] <Number of dimensions in the database>
		3 number_cubes [integer] <Number of cubes in the database>
		4 status [integer] <Status of database (0=unloaded, 1=loaded and 2=changed)>
		5 type [integer] <Type of database (0=normal, 1=system, 3=user info)>

	More info at http://host:port/api/database/rename
	'''
	#beginning of function suite
	request_name="rename"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def save(database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/save[?PARAMETER1=value[&...]].
	
	Parameters: 
		database [identifier] <Identifier of the database>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
		
	More info at http://host:port/api/database/save
	'''
	#beginning of function suite
	request_name="save"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

def unload(database, sid, host=default["host"], port=default["port"]):
	'''
	This function wraps PALO API Request
	http://[SERVER]:[PORT]/database/unload[?PARAMETER1=value[&...]].
	
	Parameters: 
		database [identifier] <Identifier of the database>
		sid [string] <Session identifier for a server connection. Use the /server/login request to get a valid session identifier.>
	
	Result:
		0 OK [boolean] <"1" means OK>
	
	More info at http://host:port/api/database/unload
	'''
	#beginning of function suite
	request_name="unload"
	#end of function suite
	return response(url(host, port, request_group, request_name, arguments(locals())))

# querys dictionary
query={}
query["cubes"]=cubes
query["create"]=create
query["destroy"]=destroy
query["dimensions"]=dimensions
query["info"]=info
query["load"]=load
query["rename"]=rename
query["save"]=save
query["unload"]=unload


#end of database module suite